package com.example.wms;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

/**
 * @author      Alexander Huynh <a.huynh @ gatech.edu>
 * @version     1.1
 * @since       2013-03-05
 */
public class HomeHandler extends Activity
{
    String username= new String("");
    String email= new String("");

    @Override public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.home_screen);
        Intent intent = getIntent();

        username = intent.getStringExtra("username");
        TextView unText = (TextView)findViewById(R.id.home_greeting);
        String str = "Welcome, " + username + ".";
        unText.setText(str);

        email = intent.getStringExtra("email");
        TextView unContact = (TextView)findViewById(R.id.home_contactField);
        //str = email;
        unContact.setText(email);
    }
    /**
     * Called when the "Lost" button is pressed. Goes to the Lost screen.
     *
     * @param view  the content view
     */
    public void startLost(View view)
    {
        // go to new lost item screen
        //Toast.makeText(HomeHandler.this, "Going to New Lost Item",Toast.LENGTH_LONG).show();
        Intent addIntent = new Intent(this, AddItemActivity.class);
        addIntent.putExtra("username", username);
        startActivity(addIntent);
    }
    /**
     * Called when the "Found" button is pressed. Goes to the Found screen.
     *
     * @param view  the content view
     */
    public void startFound(View view)
    {
        Toast.makeText(HomeHandler.this, "Going to New Found Item",Toast.LENGTH_LONG).show();
    }
    /**
     * Called when the "My Lost Items" button is pressed. Goes to the My Lost Items screen.
     *
     * @param view  the content view
     */
    public void startFoundList(View view)
    {
        Toast.makeText(HomeHandler.this, "Going to Found List",Toast.LENGTH_LONG).show();
    }
    /**
     * Called when the "My Found Items" button is pressed. Goes to the My Found Items screen.
     *
     * @param view  the content view
     */
    public void startLostList(View view)
    {
        Intent addIntent = new Intent(this, itemListViewActivity.class);
        Log.v("Home", "Making a List View.");
        startActivity(addIntent);
        //Toast.makeText(HomeHandler.this, "Going to Lost List",Toast.LENGTH_LONG).show();
    }
    /**
     * Called when the "Admin settings" button is pressed. Goes to the Admin screen.
     *
     * @param view  the content view
     */
    public void gotoAdmin(View view)
    {
        Intent adminIntent = new Intent(this, AdminHandler.class);
        startActivity(adminIntent);
    }
    /**
     * Called when the "Logoff" button is pressed. Returns to the login screen.
     *
     * @param view  the content view
     */
    public void logoff(View view)
    {
        finish();
    }
}
